package com.aaa.controller;

import com.aaa.entity.*;
import com.aaa.service.OutinstoreService;
import com.aaa.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 药房相关接口
 */
@Controller
//负责跳转页面controller
@RequestMapping("dsnavigation")
public class PathstoreController {
    @Autowired
    private StoreService storeService;
    @Autowired
    private OutinstoreService outinstoreService;
//进入库房查询
    @RequestMapping("store")
    public Object store(){
        return "drugstore/c_store";
    }
    //进入库房查询
    @RequestMapping("pharymacyhtml")
    public Object pharymaryhtml(){
        return "drugstore/c_pharmacy";
    }
    //库房药品查询
    @RequestMapping("selectdurg")
    public Object selectdurg() {
        return "drugstore/c_selectDrug";
    }
    //库房药品查询
    @RequestMapping("recycle")
    public Object recycle() {
        return "drugstore/c_recycle";
    }
    /**
     * 库房药品出库
     */
    @RequestMapping("selectchuku")
    @ResponseBody
    public R selectchuku(Model model) {
        System.out.print("进入出库");
        int selbaoquecount = outinstoreService.selbaoquecount();
        //在进入出库时查询报缺单有几条报缺显示在表头
//        model.addAttribute("selbaoquecount",selbaoquecount);

        return R.ok().entity(selbaoquecount);
    }
    /**
     * 进入药品日期报警
     */
    @RequestMapping("seldrugDate")
    @ResponseBody
    public Object seldrugDate(Drugstore drugstore, Model model) {
        int selcountlessnum = storeService.selcountlessnum();
//        model.addAttribute("selcountlessnum",selcountlessnum);

        return R.ok().entity(selcountlessnum);
    }
    //进入药品报缺
    @RequestMapping("selectless")
    public Object selectless(Model model) {
        return "drugstore/c_lackdrug";
    }
    /**
     * 进入药品入库
     */
    @RequestMapping("beputinstorage")
    @ResponseBody
    public Object beputinstorage(Upplier upplier, Warehuose warehuose, Skull skull, Model model){
        //查询供货商，经办人，库房
        List<Upplier> selupp = storeService.selupplier(upplier);
        List<Skull> selsku = storeService.selskull(skull);
        List<Warehuose> selwar = storeService.selwarehuose(warehuose);
        model.addAttribute("selupp",selupp);
        model.addAttribute("selsku",selsku);
        model.addAttribute("selwar",selwar);
        System.out.print(warehuose.getSupplierName());
        Map<String,List<?>> dataMap=new HashMap<String,List<?>>(){{
            put("selupp",selupp);
            put("selsku",selsku);
            put("selwar",selwar);

        }};
        return R.ok().entity(dataMap);
    }
//进入操作记录页面
    @RequestMapping("record")
    public  Object record(){


        return "drugstore/c_record";
    }
}
